package com.xiaxinyu.redis.client.controller;

import com.xiaxinyu.redis.client.service.RedisCounter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author XIAXINYU3
 * @date 2021/6/8
 */
@RestController
public class RedisCounterController {
    @Autowired
    RedisCounter redisCounter;

    @GetMapping("/counter/invoke")
    public String invoke() {
        redisCounter.test();
        return "success";
    }

    @GetMapping("/counter/result")
    public String result() {
        return redisCounter.get();
    }

    @GetMapping("/key/counter")
    public String testKey() {
        redisCounter.set(10001);
        return redisCounter.get();
    }
}
